/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package graph;

import java.util.Comparator;

/**
 *
 * @author borysfan
 */
public class DijkstraResultComparatorByDist implements Comparator {
    private static double eps = 10e-9;
    public int compare(Object o1, Object o2) {
        if(o1 instanceof DijkstraResult && o2 instanceof DijkstraResult){
            DijkstraResult dr1 = (DijkstraResult)o1;
            DijkstraResult dr2 = (DijkstraResult)o2;
            if(Math.abs(dr1.getDistance()-dr2.getDistance())<eps) return 0;
            if((dr1.getDistance()-dr2.getDistance())>0) return 1;
            else return -1;
        }
        return -1;
    }

}
